package com.zq.zhufengfm.entity.discoverrecommened;

/**
 * Project_name : ZhuFengFM
 * Author : zhaoQiang
 * Date : 2015/10/22,19:27
 * Email : zhaoq_hero@163.com
 */

import com.zq.zhufengfm.entity.Parseable;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.LinkedList;
import java.util.List;

/**
 * 轮播广告的实体类：
 */
public class DiscoverRecommendTopPicAds implements Parseable{

    /**
     * {
     "id": 3597,
     "shortTitle": "中国每天2亿人乘电梯，安全吗？",
     "longTitle": "中国每天2亿人乘电梯，安全吗？",
     "pic": "http://fdfs.xmcdn.com/group15/M06/52/77/wKgDaFW16vfD9nFSAAHBRSk6xm4459_android_large.jpg",
     "type": 2,
     "uid": 30495264,
     "albumId": 2814299,
     "isShare": false,
     "is_External_url": false
     },
     */
    private String shortTitle;

    private String longTitle;

    private String pic;

    private int type ;

    private List<String> picAds;

    @Override
    public void parseJSON(JSONObject json) throws JSONException {

        if (json != null) {
            JSONArray array = json.getJSONArray("list");

            picAds = new LinkedList<String>();

            for (int i = 0; i < array.length(); i++) {

                JSONObject obj = (JSONObject) array.get(i);
                shortTitle = obj.optString("shortTitle");
                longTitle = obj.optString("longTitle");
                pic = obj.getString("pic");
                type = obj.getInt("type");

                picAds.add(pic);

            }
        }
    }

    public String getShortTitle() {
        return shortTitle;
    }

    public String getLongTitle() {
        return longTitle;
    }

    public String getPic() {
        return pic;
    }

    public int getType() {
        return type;
    }

    public List<String> getPicAds() {
        return picAds;
    }
}
